package com.sz.common.core.system.service.impl;

import com.sz.common.base.service.AbstractService;
import com.sz.common.core.system.entity.Permission;
import com.sz.common.core.system.service.PermissionService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Function: PermissionServiceImpl <br>
 * Author: hpeng.wang <br>
 * Date: 2016-10-26 13:41
 */
@Service("permissionService")
public class PermissionServiceImpl extends AbstractService implements PermissionService {
    @Override
    protected String getMapperNamespace() {
        return "PermissionMapper";
    }

    @Override
    public List<Permission> findPermissionListByIds(List<Integer> permissionIds) {
        if (permissionIds == null || permissionIds.size() == 0) {
            return new ArrayList<>();
        }
        List<Permission> permissionList = dao.findForList(getSqlName("findPermissionListByIds"), permissionIds,
                Permission.class);
        return permissionList;
    }

    @Override
    public List<Permission> findPermissionListByMenuId(Integer menuId, int domainId) {
        if (menuId == null) {
            return new ArrayList<>();
        }
        Map<String, Integer> map = new HashMap<>();
        map.put("menuId", menuId);
        map.put("domainId", domainId);
        List<Permission> permissionList = dao.findForList(getSqlName("findPermissionListByRoleId"), map,
                Permission.class);
        return permissionList;
    }
}
